<script lang="ts" setup>
import {ref} from 'vue'
import {departmentGetList} from '@/api/department'

interface DepartmentItem {
  id: number;         // 确保与API返回的ID类型一致
  department_id:number | null; // 部门名称
  department:string// 可根据实际API返回字段扩展
}
defineProps({
  modelValue:{
    type:[Number,null]
  }
})
const list  = ref<DepartmentItem[]>([])
const emit = defineEmits(['update:modelValue'])
const getList = async()=>{
  const res = await departmentGetList()
  
  list.value = res.data.data
  
}
getList()
</script>

<template>
<el-select  :modelValue="modelValue" placeholder="请选择部门"
@update:modelValue="emit('update:modelValue',$event)">
    <el-option  v-for="select in list" :key="select.id" :label="select.department"  :value="select.id"> 
    </el-option>
</el-select>

</template>

<style lang="scss" scoped></style>